package com.ruoyi.web.controller.goods;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.goods.domain.Goods;
import com.ruoyi.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController extends BaseController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/queryByPage")
    public TableDataInfo queryByPage(Goods goods) {
        return getDataTable(goodsService.queryByPage(goods));
    }

    @GetMapping("/getList")
    public TableDataInfo getList() {
        return getDataTable(goodsService.getList());
    }

    @PostMapping("/insert")
    public AjaxResult insert(Goods goods) {
        return success(goodsService.insert(goods));
    }

    @PostMapping("/update")
    public AjaxResult update(Goods goods) {
        return success(goodsService.update(goods));
    }

    @DeleteMapping("/delByIds/{ids}")
    public AjaxResult delByIds(@PathVariable Long[] ids) {
        return success(goodsService.delByIds(ids));
    }
}
